Skip to content

Adds permanent magnet DC machine #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 4, 2022
Merged

Conversation

ValentinKaisermayer
Copy link
Contributor

No description provided.

@ValentinKaisermayer
Copy link
Contributor Author

The DC motor on its own works:
dc_motor

However, there is again that key not found error for other setups.

@codecov
Copy link

codecov bot commented May 8, 2022

Codecov Report

Merging #49 (6eeb99c) into main (2b53d55) will increase coverage by 2.66%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #49      +/-   ##
==========================================
+ Coverage   68.03%   70.70%   +2.66%     
==========================================
  Files          25       25              
  Lines        1214     1198      -16     
==========================================
+ Hits          826      847      +21     
+ Misses        388      351      -37     
Impacted Files Coverage Δ
src/Mechanical/Rotational/sources.jl 85.00% <ø> (ø)
src/Electrical/Analog/ideal_components.jl 100.00% <100.00%> (ø)
src/Mechanical/Rotational/components.jl 100.00% <100.00%> (+11.11%) ⬆️
src/Mechanical/Rotational/utils.jl 92.30% <100.00%> (+18.83%) ⬆️
src/Blocks/math.jl 100.00% <0.00%> (+6.17%) ⬆️
src/Blocks/sources.jl 100.00% <0.00%> (+7.54%) ⬆️
src/Electrical/utils.jl 76.19% <0.00%> (+12.19%) ⬆️
src/Thermal/HeatTransfer/sources.jl 100.00% <0.00%> (+19.23%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ChrisRackauckas
Copy link
Member

As a general principle, anything that you would not expect to be true for 99% of models should be required. So for example, if you know that in a given model everyone always uses the normalized units of 1, then sure make that value hardcoded as a keyword argument. If there's a tolerance that is like "this is the level that everyone tends to use because it's small enough that plots look correct", then 👍. If it's a value that you expect everyone to change, like the inductance, then it should be required.

@ChrisRackauckas
Copy link
Member

This is doing a lot. Can this be rebased? Are there pieces that should be individual PRs?

@ValentinKaisermayer
Copy link
Contributor Author

This is doing a lot. Can this be rebased? Are there pieces that should be individual PRs?

  • There are some formatting changes in Electrical that could be a separate PR.
  • There is an addition to the test where I added checks for the return code.

Copy link
Member

@YingboMa YingboMa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems some of the components are not needed for DCPM. Does it make sense to split this PR a bit?

@ValentinKaisermayer ValentinKaisermayer marked this pull request as draft June 10, 2022 18:03
@ValentinKaisermayer ValentinKaisermayer force-pushed the dcpm branch 2 times, most recently from 46d3144 to be93225 Compare September 25, 2022 08:55
@ValentinKaisermayer ValentinKaisermayer changed the title Dcpm Adds permanent magnet DC machine Sep 26, 2022
@ValentinKaisermayer ValentinKaisermayer marked this pull request as ready for review September 26, 2022 18:51
sys = structural_simplify(model)
prob = ODEProblem(sys, [], (0, 6.0))
sol = solve(prob, Rodas4())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using

prob = ODAEProblem(sys, [], (0, 6.0))
sol = solve(prob, Rodas4())

will result in

ERROR: UndefVarError: pi_controller₊err_input₊u(t) not defined
Stacktrace:
  [1] macro expansion
    @ .julia\dev\ModelingToolkit\src\structural_transformation\codegen.jl:199 [inlined]
  [2] macro expansion
    @ .julia\packages\SymbolicUtils\qulQp\src\code.jl:351 [inlined]
  [3] macro expansion
    @ C:\Users\kaisv.TUGRAZ\.julia\packages\RuntimeGeneratedFunctions\KrkGo\src\RuntimeGeneratedFunctions.jl:129 [inlined]
  [4] macro expansion
    @ .\none:0 [inlined]
  [5] generated_callfunc
    @ .\none:0 [inlined]
  [6] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#14840964602010972036"), Symbol("##arg#18305951688076727758"), :t), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0x8b4a2f6c, 0xa9522116, 0x134b5081, 0x0a8c04c2, 0x33f2532d)})(::Vector{Float64}, ::Vector{Float64}, ::Float64)
    @ RuntimeGeneratedFunctions .julia\packages\RuntimeGeneratedFunctions\KrkGo\src\RuntimeGeneratedFunctions.jl:117

so that it can be represented as a system of `ODEs` (ordinary differential equations).

```@example dc_motor_pi
sys = structural_simplify(model)
Copy link
Contributor Author

@ValentinKaisermayer ValentinKaisermayer Oct 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to all Blocks.RealInputs being marked as input=true even the simplified system has a whopping 19 states:

julia> states(sys)
19-element Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}:
 pi_controller₊int₊x(t)
 L1₊i(t)
 inertia₊phi(t)
 inertia₊w(t)
 pi_controller₊gainPI₊input₊u(t)
 pi_controller₊addPI₊input1₊u(t)
 pi_controller₊addPI₊input2₊u(t)
 pi_controller₊int₊input₊u(t)
 pi_controller₊addTrack₊input1₊u(t)
 pi_controller₊addTrack₊input2₊u(t)
 pi_controller₊limiter₊input₊u(t)
 pi_controller₊addSat₊input1₊u(t)
 pi_controller₊addSat₊input2₊u(t)
 pi_controller₊gainTrack₊input₊u(t)
 feedback₊input2₊u(t)
 feedback₊input1₊u(t)
 source₊V₊u(t)
 load₊tau₊u(t)
 pi_controller₊err_input₊u(t)

])
sys = structural_simplify(model)

@test_broken prob = ODAEProblem(sys, Pair[], (0, 6.0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this fail with? Have you tried ODEProblem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ODAEProbem construction works fine but solve errors. ODEProblem works. SciML/ModelingToolkit.jl#1867

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test with ODEProblem?

@YingboMa YingboMa merged commit 28ad75d into SciML:main Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants